#ifndef _VN_HEALTH_COMPONENT_H_
#define _VN_HEALTH_COMPONENT_H_

#include "IComponent.h"
#include <functional>

class HealthComponent : public IComponent
{
public:
	HealthComponent(int p_minHealth, int p_maxHealth, float p_delayTime = 0.0f);
	virtual ~HealthComponent(void);

	virtual void init();
	virtual void update(const GameTime&);

	virtual const std::string getType() { return "HealthComponent"; }
	virtual const std::string getFamilyType() { return "HealthComponent"; }

	virtual void decreaseHealth(int);
	virtual void increaseHealth(int);
	virtual void setHealth(int);

	void setMaxHealth(int p_value) { m_maxHealth = p_value; }
	void setMinHealth(int p_value) { m_minHealth = p_value; }

	int getHealth() const			{ return m_health; }
	int getMaxHealth() const		{ return m_maxHealth; }
	int getMinHealth() const		{ return m_minHealth; }
	bool canReceiveDamage() const	{ return m_canReceiveDamage; }
	void setDeathCallback(std::function<void()> p_deathCallback) { m_deathCallback = p_deathCallback; }

protected:
	int m_health;
	int m_maxHealth;
	int m_minHealth;
	float m_targetTime;
	float m_elapsedTime;
	bool m_canReceiveDamage;
	std::function<void()> m_deathCallback;
};

#endif // _VN_HEALTH_COMPONENT_H_